package string;
/**
 * String replaceAll(String regex, String replacement)
 * 将当前字符串满足正则表达式(regex)的部分替换为给定内容(replacement)
 * */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        String str = "abc123def456ghi";
        str = str.replaceAll("[0-9]+","NUNBER");//将数字部分替换为#NUMBER#
        System.out.println(str);//abc123def456ghi ---> abcNUNBERdefNUNBERghi

        //和谐用语
        String regex = "(gun|sha|sb)";//不和谐关键字
        String message = "你sb,gun吧";//不和谐语句
        message = message.replaceAll(regex,"***");//将相关的词语用***代替, 大到和谐文字的作用
        System.out.println(message);

    }
}
